package com.hp.weather.controller;

import com.hp.weather.service.WeatherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author haopeng
 */
@Controller
public class IndexController {

    @Autowired
    private WeatherService weatherService;

    @GetMapping("/")
    public String getWeatherData(@RequestParam(value = "location", required = false, defaultValue = "西安") String location, ModelMap map) {
        map.put("data", weatherService.getWeatherDataByLocation(location));
        return "/weather/report";

    }

}
